import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
import login from '@/views/login/login.vue'
import layout from '@/views/layout/layout.vue'
import chart from '@/views/layout/chart/chart.vue'

import business from '@/views/layout/business/business.vue'
import question from '@/views/layout/question/question.vue'
import subject from '@/views/layout/subject/subject.vue'
import userList from '@/views/layout/userList/userList.vue'
const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: 'login'
        },
        {
            path: '/login',
            component: login,
            meta:{
                title:'登录'
            }
        }, {
            path: '/layout',
            component: layout,
            children: [
                {
                    path: '/',
                    redirect: 'subject',
                    meta:{
                        title:'学科列表'
                    }
                },
                {
                    path: '/layout/chart',
                    component: chart,
                    meta:{
                        title:'数据列表'
                    }
                },
                {
                    path: '/layout/userList',
                    component: userList,
                    meta:{
                        title:'用户列表'
                    }
                },
                {
                    path: '/layout/question',
                    component: question,
                    meta:{
                        title:'题库列表'
                    }
                },
                {
                    path: '/layout/business',
                    component: business,
                    meta:{
                        title:'企业列表'
                    }
                },
                {
                    path: '/layout/subject',
                    component: subject,
                    meta:{
                        title:'学科列表'
                    }
                },
            ]
        }
    ]
})



import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'
//路由前置守卫
router.beforeEach((to,form,next)=>{
    Nprogress.start();
    next();
});
//进入后拦截   路由后置守卫
router.afterEach((to,form)=>{

    document.title = to.meta.title;
    Nprogress.done();
    console.log('to',to);
    console.log('form',form);
})
export default router